package com.compassoft.webapp.action;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.vipshop.compass.dao.UserDao;
import com.vipshop.compass.domain.User;

//@Controller("UserAction")
//@Scope("prototype")
//@ParentPackage("struts-default")
@Namespace("/user")
public class UserAction extends ActionSupport {
	private static final long serialVersionUID = -2689736136098568594L;

	private UserDao userDao;
	
	private String username;
	private String password;
	private String rememberMe;
	private List<User> userList;

	// for more, @see http://struts.apache.org/release/2.2.x/docs/convention-plugin.html
	@RequiresRoles(value = { "ROLE_ADMIN" })
	@Action(value = "list")
	public String list() {
//	    System.out.println("list--------------------"+username);
//	    if (StringUtils.isEmpty(username)) {
//	        return INPUT;
//	    }
	    userList = userDao.getAll();
//	    System.out.println("userList-------------------"+userList);
		return SUCCESS;
	}

	/**
	 * 这个还用说咩： 来源于 info.addStringPermission("user:edit");
	 * 
	 * @return
	 */
//	@RequiresPermissions("user:edit")
	@Action(value = "update")
	public String update() {
	    System.out.println("username="+username);
	    System.out.println("password="+password);
		System.out.println("update............");
		return SUCCESS;
	}

	public String logout() {

		return "logout";
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public String getRememberMe() {
		return rememberMe;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setRememberMe(String rememberMe) {
		this.rememberMe = rememberMe;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

    
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

}
